package com.project.controller.GoodsController;

import com.github.pagehelper.PageInfo;
import com.project.bean.GoodsBean;
import com.project.service.GoodsService.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Goods")
public class GoodsController {
    @Autowired
    private IGoodsService service;

    @RequestMapping("/findByItem")
    public PageInfo<GoodsBean> findByItem(int pageNO, String name, String type, Integer startNum, Integer endNum){
        return service.findByItem(pageNO, name, type, startNum, endNum);
    }

    @RequestMapping("/addGoods")
    public String addGoods(GoodsBean goods){
        service.addGoods(goods);
        return "ok";
    }

    @RequestMapping("/findById")
    public GoodsBean findById(int goodsId){
        return service.findById(goodsId);
    }

    @RequestMapping("/updatePrice")
    public String updatePrice(int goodsId, int newPrice){
        service.updatePrice(goodsId, newPrice);
        return "ok";
    }

    @RequestMapping("/updateNumber")
    public String updateNumber(int goodsId, int newNum){
        service.updateNumber(goodsId, newNum);
        return "ok";
    }
}
